package com.quick.springbootquicky.mapper;

import com.quick.springbootquicky.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    /**
     * 添加数据
     * @param category
     */
    @Insert("insert into category(category_name,category_alise,create_user,create_time,update_time)" +
            " values(#{categoryName},#{categoryAlise},#{createUser},now(),now())")
    void add(Category category);

    /**
     * 根据当前登录用户查询
     * @param userId
     * @return
     */
    @Select("select * from category where create_user =#{userId}")
    List<Category> list(Integer userId);

    /**
     * 根据文章id查询信息
     * @param id
     * @return
     */
    @Select("select * from category where id =#{id}")
    Category findById(Integer id);
    /**
     * 根据文章id更新文章
     * @param category
     */
    @Update("update category set category_name=#{categoryName},category_alise=#{categoryAlise},update_time=#{updateTime} where id=#{id}")
    void update(Category category);

    @Delete("delete from category  where id =#{id}")
    void delete(Integer id);
}
